/*
 *  Input Range Customization by browser
 */

// The following code is inspired by...

// Github: https://github.com/darlanrod/input-range-sass
// Author: Darlan Rod https://github.com/darlanrod
// Version 1.4.1
// MIT License

// It has been modified to fit the styling patterns of Kibana and
// to be more easily maintained / themeable going forward.

.euiRangeSlider {
  height: $euiFormControlHeight;
  appearance: none;
  background: transparent; // Otherwise white in Chrome
  width: 100%; // ensures the slider expands to fill flex display
  position: relative;
  cursor: pointer; // Keep cursor to full range bounds

  &:disabled {
    cursor: not-allowed;

    // sass-lint:disable-block mixins-before-declarations
    @include euiRangeThumbPerBrowser {
      cursor: not-allowed;
      border-color: $euiRangeThumbBorderColor;
      background-color: $euiRangeThumbBorderColor;
      box-shadow: none;
    }

    ~ .euiRangeThumb {
      cursor: not-allowed;
      border-color: $euiRangeThumbBorderColor;
      background-color: $euiRangeThumbBorderColor;
      box-shadow: none;
    }
  }

  @include euiRangeThumbPerBrowser {
    @include euiCustomControl($type: 'round');
    @include euiRangeThumbStyle;
  }

  @include euiRangeTrackPerBrowser {
    @include euiRangeTrackSize;
    background: $euiRangeTrackColor;
    border: $euiRangeTrackBorderWidth solid $euiRangeTrackBorderColor;
    border-radius: $euiRangeTrackRadius;
  }

  &:focus,
  &--hasFocus {
    @include euiRangeThumbPerBrowser {
      @include euiCustomControlFocused;
    }

    ~ .euiRangeThumb {
      border-color: $euiColorPrimary;
    }

    @include euiRangeTrackPerBrowser {
      background-color: $euiColorPrimary;
      border-color: $euiColorPrimary;
    }

    ~ .euiRangeHighlight .euiRangeHighlight__progress {
      background-color: $euiColorPrimary;
    }

    ~ .euiRangeTooltip .euiRangeTooltip__value {
      @include euiBottomShadowMedium;

      &.euiRangeTooltip__value--right,
      &.euiRangeTooltip__value--left {
        transform: translateX(0) translateY(-50%) scale(1.1);
      }
    }
  }

  // Resets

  // Disable linter for these very unique vendor controls
  // sass-lint:disable-block no-vendor-prefixes
  &::-webkit-slider-thumb {
    -webkit-appearance: none;
    margin-top: ((-$euiRangeTrackBorderWidth * 2 + $euiRangeTrackHeight) / 2) -
      ($euiRangeThumbHeight / 2);
  }

  &::-ms-thumb {
    margin-top: 0;
  }

  &::-moz-focus-outer {
    border: none;
  }

  &::-ms-track {
    @include euiRangeTrackSize;
    background: transparent;
    border-color: transparent;
    border-width: ($euiRangeThumbHeight / 2) 0;
    color: transparent;
  }

  // States
  &--hasTicks {
    height: $euiFormControlHeight / 2; // Adjust vertical alignment based on extras
  }

  &--compressed {
    height: $euiFormControlCompressedHeight;

    &.euiRangeSlider--hasTicks {
      height: $euiFormControlCompressedHeight / 2;
    }
  }
}

// Lighten the track when showing the range
.euiRangeSlider--hasRange {
  @include euiRangeTrackPerBrowser {
    background-color: transparentize($euiRangeTrackColor, 0.6);
    border-color: transparentize($euiRangeTrackBorderColor, 0.6);
  }
}
